import java.util.*;

/**
 * 空瓶子换汽水 问题
 */
public class Main{
    public static void main(String[]args) {
        Scanner sc= new Scanner(System.in);
        while( sc.hasNextInt()) {
            int n = sc.nextInt();
            int count = 0;
            if( n ==0 ) {
                return ;
            }
            if( n==1 || n==2) {
                System.out.println(0);

            } else {
                int t = 0;
                int sy = 0;
                while( n>= 3) {
                   t = n/3;
                   sy = n%3;
                   n = t+sy;
                   if(n==2) {
                       n++;
                   }
                   count += t;
                }
                System.out.println(count);
            }

            
        }
    }
}